#define _CRT_SECURE_NO_DEPRECATE
#define _SECURE_SCL 0
#pragma comment(linker, "/STACK:66777216")
#include <algorithm>
#include <string>
#include <complex>
#include <cassert>
#include <memory>
#include <set>
#include <stack>
#include <map>
#include <list>
#include <deque>
#include <numeric>
#include <cctype>
#include <cstddef>
#include <vector>
#include <queue>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <sstream>
#include <fstream>
#include <ctime>
#include <cstring>
#include <functional>
#include <bitset>
using namespace std;
 
#if defined(_MSC_VER) || defined(__BORLANDC__)
    typedef unsigned __int64 uint64;
    typedef signed __int64 int64;
#else
    typedef unsigned long long uint64;
    typedef signed long long int64;
#endif
typedef vector<int> VI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef pair<int64,int64> PLL;
typedef vector<int64> VL;
 
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pdd pair<double,double>
#define FOR(i,a,b) for (int _n(b), i(a); i <= _n; i++)
#define FORD(i,a,b) for(int i=(a),_b=(b);i>=_b;i--)
#define all(c) (c).begin(), (c).end()
#define SORT(c) sort(all(c))
#define REP(i,n) FOR(i,1,(n))
#define REPT(i,n) FOR(i,0,(n)-1)
#define L(s) (int)((s).size())
#define C(a) memset((a),0,sizeof(a))
#define IOS ios::sync_with_stdio(false)
 
const double pi = 3.1415926535897932384626433832795028841971;
const double EPS = 1E-9;
const int64 INF64 = (int64)1E18;
const int INF = 1000000000;
 
static inline bool get(int &v)
{
    int s = 1, c;
    while(!isdigit(c = getchar())&&c != '-')
    {
        if(c == EOF)
            break ;
    }
    if(c == EOF) return 0;
    if(c == '-') s = 0 , v = 0;
    else v = c^48;
    for(;isdigit(c = getchar());v = (v << 1) + (v << 3) + (c ^ 48));
    v = (s ? v : -v);
    return 1 ;
}

vector< pair<int, int> > adj[1050];
int n, k, m, ds, a, b, w, s, t;
int dist[1050];
int vis[1050];
//比较station到house相距最小距离的最大， 然后总距离最小。
//题意就是坑，spfa就ok了。
bool spfa(int ind, int &mindis, int &sumdis)
{
	REPT(i, n+k+1)
	{
		dist[i] = INF;
		vis[i] = 0;
	}

	queue<int> q;
	q.push(ind);
	dist[ind] = 0;
	vis[ind] = 1;
	while (!q.empty())
	{
		int cur = q.front();
		q.pop();
		vis[cur] = 0;
		REPT(i, adj[cur].size())
		{
			if (dist[adj[cur][i].first] > dist[cur] + adj[cur][i].second)
			{
				dist[adj[cur][i].first] = dist[cur] + adj[cur][i].second;
				if (!vis[adj[cur][i].first])
				{
					q.push(adj[cur][i].first);
					vis[adj[cur][i].first] = 1;
				}
			}
		}
	}
	mindis = INF;
	sumdis = 0;
	FOR(i, 1, n)
	{
		if (dist[i] > ds)
		{
			return false;
		}
		else
		{
			mindis = min(mindis, dist[i]);
			sumdis += dist[i];
		}
	}
	return true;
}



void run()
{
	char ch;
	cin >> n >> k >> m >> ds;
	cin.get();
	REPT(i, m)
	{
		cin.get(ch);
		if (ch == 'G')
		{
			cin >> a;
			s = n+a;
		}
		else
		{
			cin.putback(ch);
			cin >> a;
			s = a;
		}
		cin.get();
		cin.get(ch);
		if (ch == 'G')
		{
			cin >> b;
			t = n+b;
		}
		else
		{
			cin.putback(ch);
			cin >> b;
			t = b;
		}
		cin >> w;
		cin.get();
		adj[s].push_back(make_pair(t, w));
		adj[t].push_back(make_pair(s, w));
	}
	int ansSumDis = INF;
	int ansMinDis = -INF;
	int ansInd = -1;
	int curMinDis,curSumDis;
	FOR(i, n+1, n+k)
	{
		if (spfa(i, curMinDis, curSumDis))
		{
			if (curMinDis > ansMinDis || ((curMinDis == ansMinDis) && curSumDis < ansSumDis))
			{
				ansSumDis = curSumDis;
				ansMinDis = curMinDis;
				ansInd = i;	
			}			
		}
	}
	if (ansInd == -1)
	{
		cout << "No Solution" << endl;
	}
	else
	{
		cout << "G" << ansInd-n << endl;
		printf("%.1lf %.1lf\n", (double)ansMinDis, (double)ansSumDis/(double)n);
	}
}

 
 
int main()
{
#ifdef __DEBUG__
    freopen("test.in","r",stdin);
    freopen("test.out","w",stdout);
    time_t st = clock();
#endif
    run();
#ifdef __DEBUG__
    printf( "\n=============\n");
    printf("Time: %.2lf sec\n",(clock()-st)/double(CLOCKS_PER_SEC));
#endif
    return 0;
}
